package net.cmkj.mine.util;

import java.util.List;

import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import net.cmkj.mine.common.model.DataGridModel;

public final class DataGridModelUtils {

	@SuppressWarnings("rawtypes")
	public static DataGridModel toDataGridView(Page pageInfo){
		DataGridModel dataGridView=new DataGridModel();
		dataGridView.setCode(0);
		dataGridView.setMsg("");
		dataGridView.setCount(pageInfo.getTotalRow());
		dataGridView.setData(pageInfo.getList());
		return dataGridView;
	}
	
	@SuppressWarnings("rawtypes")
	public static DataGridModel toDataGridView(Page pageInfo, Record sumRec){
		DataGridModel dataGridView=new DataGridModel();
		dataGridView.setCode(0);
		dataGridView.setMsg("");
		dataGridView.setCount(pageInfo.getTotalRow());
		dataGridView.setSumRec(sumRec);
		dataGridView.setData(pageInfo.getList());
		return dataGridView;
	}
	
	@SuppressWarnings("rawtypes")
	public static DataGridModel toDataGridView(Page pageInfo, double sum){
		DataGridModel dataGridView=new DataGridModel();
		dataGridView.setCode(0);
		dataGridView.setMsg("");
		dataGridView.setCount(pageInfo.getTotalRow());
		dataGridView.setSum(sum);
		dataGridView.setData(pageInfo.getList());
		return dataGridView;
	}
	
	@SuppressWarnings("rawtypes")
	public static DataGridModel toDataGridView(List list){
		DataGridModel dataGridView=new DataGridModel();
		dataGridView.setCode(0);
		dataGridView.setMsg("");
		dataGridView.setCount(list.size());
		dataGridView.setData(list);
		return dataGridView;
	}
}
